<?php
$this->breadcrumbs=array(
	'Issues'=>array('index'),
	'Assign',
);

$this->menu=array(
	array('label'=>'List Issue', 'url'=>array('index')),
	array('label'=>'Create Issue', 'url'=>array('create')),
);
?>

<h1>Checker's page</h1>
<h3>Assign to resolve the question to resolver and check the answer which submit by resolver.</h3>


<div class="grid-view">
<table border="1" class="items">
	<thead>
		<tr>
			<th>Issue</th>
			<th>Câu hỏi</th>
			<th>Trạng thái bài giải</th>
			<th>Thời gian</th>
			<th>Resolver</th>
			<th>Action</th>
		</tr>
	</thead>
	<tbody>
<?php
		$this->widget('zii.widgets.CListView', array(
		'id'=>'assign-issue-list',
		'dataProvider'=>$model->assign($ID),
		'pager'=>array
		(
			'firstPageLabel' => '&lt;&lt;',
	    'prevPageLabel'  => '&lt;',
	    'nextPageLabel'  => '&gt;',
	    'lastPageLabel'  => '&gt;&gt;',
			'header'=>'',
		),
		'emptyText'=>'Không có dữ liệu.',
		'itemView'=>'_view_assign',
	)); ?>
	
	
	</tbody>
</table>	
</div>

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->baseUrl; ?>/css/tables.css">	
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->baseUrl; ?>/css/simplemodal/basic.css">
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl; ?>/js/countdown.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl; ?>/js/simplemodal/jquery.simplemodal.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl; ?>/js/simplemodal/basic.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl; ?>/js/simplemodal/popup.js"></script>

<script type="text/javascript">
$(function() {
	$(".refresh").click(function() {
		console.log($(this));
		$(this).parent().children(".btn-success").removeAttr("disabled").removeClass("disabled");
		$(this).parent().children(".btn-inverse").removeAttr("disabled").removeClass("disabled");
	});

	$(".countdown").each(function() {
		if($(this).html()>0) {
			var arr_bt = $(this).attr("id").split("_");
		  var bt = arr_bt[1];
		  var issueID = arr_bt[2];
		  timer(
				  bt,
				  1000*($(this).html()),
				  function(timeleft) {

					  var time = "<button class='disabled btn btn-info'><i class='icon-time icon-white'></i>"+timeleft+"</button>"
						$("#countdown_"+bt+"_"+issueID).html(time);
						
					},
					function() {
						submitResolve(issueID, bt);
					}
			);
		}
	});

	
});
function beforeAssign(resolverID,issueID,num,status) {
	//var resolverID = $("#issue_"+issueID+"_"+num).val();
	if(status=="confirm") {
		if(!confirm('Bạn có muốn tiếp tục thực hiện hành động này?')) {
			return false;
		}
	}
	$.ajax({
		url: baseUrl + "/admin/issue/setAssign",
		data: {issueID: issueID, resolverID: resolverID, status: status, num: num},
		type: "POST",//or GET
		success: function(data) {			
			if(data!="") {
				alert(data);
				$("#"+status+"_"+issueID+"_"+num).addClass("disabled").attr("disabled","disabled").hide();
			}
		}
	});
}
</script>






